#URL = "ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-%(VERSION)s.tar.bz2"
URL = "http://downloads.sourceforge.net/project/pcre/pcre/%(VERSION)s/pcre-%(VERSION)s.tar.bz2"
VERSIONS = ["8.02"]
DEFAULT_VERSION = "8.02"
DEPENDS = ["zlib"]

import os, shutil, subprocess
#from source.builders import CMakeBuilder, ConfigureMakeBuilder
from source.builders import CMakeBuilder

class PcreBuilder( CMakeBuilder ):
  """ subclass of CMakeBuilder with custom configure step """

  def configure( self ):
    zlibmod = self.dependencies["zlib"]
    incdir = " -DZLIB_INCLUDE_DIR="+ zlibmod.getincludedir() 
    lib = " -DZLIB_LIBRARY="+zlibmod.getlibdir()+os.sep+("libz.so", "zlib.lib")[self.machine.isWindows()]
    # FIXME: -DCMAKE_INSTALL_SO_NO_EXE=0 was added to avoid having .so files without executable permission.
    #        Clearly this is not the best solution, since this is an internal CMAKE variable. A better
    #        solution is required.
    pcreshared = (" -DBUILD_SHARED_LIBS=TRUE -DCMAKE_INSTALL_SO_NO_EXE=0", "")[self.machine.isWindows()]
    CMakeBuilder.configure(self, incdir+lib+pcreshared)

  def make_devenv(self):
    CMakeBuilder.make_devenv(self)
    
    
BUILDER = PcreBuilder

